﻿using System;
using System.Collections.Generic;
using System.Text;
using Paulovich.Data;
using Paulovich.Data.SqlBuilder;
using System.Data;

namespace DJJuninho.Business
{
    [Table("Photo")]
	public class Photo: Persist  {

		#region fields & properties

        [PrimaryKeyField(IsIdentity = true)]
		public int PhotoId { get; set; }

		[Field]
        public string Url { get; set; }

		#endregion

		#region constructors

		public Photo()
			: base() {
		}

		public Photo(params object[] keys)
			: base(keys) {
		}

		#endregion


        public static DataTable SelectOrderingByName()
        {

            try
            {

                var query = new SelectBuilder();

                query.Select.Add("PhotoId, Url");
                query.TableName = "Photo";
                query.OrderBy = "Url";

                var command = new Command();

                command.CommandText = query.ToString();

                return (DataTable)command.ExecuteQuery(ReturnType.DataTable);

            }
            catch (Exception)
            {

                throw;
            }

        }
    }
}
